<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>动态组件！！</title>
</head>
<body>
    <div id="app">
        <hentai></hentai>
    </div>
    <!--  -->
    <div></div>
    
    <script src="vue.js"></script>
    <script>
        Vue.component('hentai',{
            data(){
                return{
                    currentCpn:"milf",
                }
            },
            template:`
            <div>
                <button @click="changeCpn('milf')">milf</button>
                <button @click="changeCpn('hearm')">hearm</button>
                <button @click="changeCpn('aunt')">aunt</button>
                <div style="width:600px; height:400px;border:1px solid black;">
                    <!-- keep-alive 保持组件中的内容！！！！！！！！！！（可选） -->
                    <keep-alive>
                        <!-- :is 要动态的绑定！！！！！！！！！！！！  -->
                        <component  :is="currentCpn"></component>
                    </keep-alive>
                </div>
            </div>
            `,
            methods:{
                changeCpn(cpnName){
                    this.currentCpn = cpnName;
                },
            }
        });

        Vue.component('milf',{
            
            template:`
            <div>
                <h1>milf</h1>
                <input type="text" />
            </div>
            `,
        });

        Vue.component('hearm',{
            
            template:`
            <div>
                <h1>hearm</h1>
            </div>
            `,
        });

        Vue.component('aunt',{
            
            template:`
            <div>
                <h1>aunt</h1>
            </div>
            `,
        });

        new Vue({
            el:"#app",
            data(){
                return {
                }
            },
        })
    
    </script>
    

</body>
</html>